<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * inner short summary.
 *
 * inner description.
 *
 * @version 1.0
 * @author xianbin
 */
class inner extends Sys_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->Model('Menu_model');
        $this->load->library('ajaxMsgModel');
        $this->load->library('form_validation');
    }
    public function bannerlist()
    {
        $this->ajaxmsgmodel->Type='1';
        $this->Ajax_Check($this->ajaxmsgmodel);
        $data['top_menulist']=$this->Menu_model->get_top_level_menu();
        $this->load->view('Admin/inner/bannerlist.html',$data);
    }

    public function edit_banner()
    {
        $this->ajaxmsgmodel->Type='2';
        $this->Ajax_Check($this->ajaxmsgmodel);

        $menu_id=$this->uri->segment(4);
        $menu_model=$this->Menu_model->get_menu_by_id($menu_id);
        $data['menu_model']=$menu_model;
        $this->load->view('Admin/inner/edit_banner.html',$data);
    }

    public function edit_ajax_banner()
    {
        $this->ajaxmsgmodel->Type='4';
        $this->Ajax_Check($this->ajaxmsgmodel);

        $menu_model=new $this->Menu_model();
        $menu_model->menuid=$this->input->post('menuid');
        $menu_model->icon=$this->input->post('icon');
        $res=$this->Menu_model->update_menu_icon($menu_model);
        if($res>0)
        {
            $this->ajaxmsgmodel->Msg='修改成功';
            $this->ajaxmsgmodel->Statu='ok';
            $this->ajaxmsgmodel->BackUrl=site_url('admin/inner/bannerlist');
        }
        else
        {
            $this->ajaxmsgmodel->Msg='修改失败';
            $this->ajaxmsgmodel->Statu='err';
        }
        echo(json_encode($this->ajaxmsgmodel));
    }

    public function del_banner()
    {
        $this->ajaxmsgmodel->Type='4';
        $this->Ajax_Check($this->ajaxmsgmodel);

        $menu_id=$this->uri->segment(4);
        $res=$this->Menu_model->del_menu_icon($menu_id);
        if($res>0)
        {
            $this->ajaxmsgmodel->Msg='删除成功';
            $this->ajaxmsgmodel->Statu='ok';
            $this->ajaxmsgmodel->BackUrl=site_url('admin/inner/bannerlist');
        }
        else
        {
            $this->ajaxmsgmodel->Msg='删除失败';
            $this->ajaxmsgmodel->Statu='err';
        }
        echo(json_encode($this->ajaxmsgmodel));

    }
}